﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YasharEl.Infrastructure.EntityModel.Validation.DataAnnotations
{
    internal class DataAnnotationsEntityInspector
    {
        private IDictionary<Type, EntityMetadata> cache = new Dictionary<Type, EntityMetadata>();

        public EntityMetadata GetMetadata(Type type)
        {
            // TODO: Use write/read lock slim
            EntityMetadata result;
            if (!cache.TryGetValue(type, out result))
            {
                lock (cache)
                {
                    cache[type] = result = new EntityMetadata(type);
                }
            }
            return result;
        }
    }
}
